package com.bool.tour;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

public class SplashActivity extends AppCompatActivity {

    //延迟进入
    protected Handler mHandler = new Handler();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        //延迟进入主界面
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {

                //获取 SharedPreferences
                SharedPreferences sp = getPreferences(MODE_PRIVATE);
                //获取是否第一次进入
                boolean is_first = sp.getBoolean("is_first",true);

                //判断是否第一次进入
                if(is_first){
                    //更改状态
                    sp.edit().putBoolean("is_first",false).commit();
                    //进入引导页
                    startActivity( new Intent(SplashActivity.this, GuideActivity.class) );
                }else{
                    //进入主页
                    startActivity( new Intent(SplashActivity.this, MainActivity.class) );
                }

                //页面切换动画
                //overridePendingTransition();
//                startActivity( new Intent(SplashActivity.this, MainActivity.class) );
                //销毁界面
                finish();

            }
        },3000);

    }
}
